<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2014-11-23
 * Time: 11:05
 */

$key = 'de2141b308788f66';
$url = $_POST['url'];
$ext = explode('.', basename($url));
//print_r($ext);
$itemCodes = basename($url,'.'.$ext[1]);
//print_r($itemCodes);

$api = 'http://api.tudou.com/v6/video/info?app_key='.$key.'&format=xml&itemCodes='.$itemCodes;

$dom = new DOMDocument('1.0','utf-8');
$dom->load($api);
echo "<pre>";
print_r($api);
$urls = $dom->getElementsByTagName('outerGPlayerUrl')->item(0)->nodeValue;
?>
<!DOCTYPE html>
<html>
<head lang="zh_cn">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <h1>土豆视频去广告</h1>
    <form method="post">
        <label>
            请输入视频链接：<input type="text" name="url" >
        </label>
        <input type="submit" value="提交" />
    </form>
    <iframe src="http://www.tudou.com/programs/view/html5embed.action?code=<?php echo $itemCodes;?>&autoPlay=true" width="100%" height="524px" frameborder="0" scrolling="no"
        ></iframe>
    <video autoplay="true" src="<?php echo $urls; ?>"></video>

</body>
</html>